package com.gmd.cita.model.repository;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.gmd.cita.model.dao.MedicoDAO;
import com.gmd.model.Medico;

public class JPAMedicoDAO implements MedicoDAO{

	EntityManager em;
	
	public JPAMedicoDAO(EntityManager em){
		this.em = em;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Medico> findAll() {
		List<Medico> result;
		Query q = em.createNamedQuery("findAllMedico");
		result = q.getResultList();
		return (result != null) ?  result : new ArrayList<Medico>();
	}

}
